<template>
  <div class="func-comp-form">

    <ComponentGlobalSettingForm :id="id" :compConfigData="compConfigData"></ComponentGlobalSettingForm>

    <Tabs name="main_tabs" size="small" v-model="mainTabsValue">
      <TabPane name="main_tab" tab="main_tabs" label="主配置">

        <Collapse value="0">
          <Panel>
            常规配置
            <div slot="content">
              <Alert style="padding: 8px;">
                由于斑马柱状图组件的特殊性，是否含坐标轴配置将无法生效
              </Alert>
              <EchartsGridConfigForm v-model="chartOption.grid"></EchartsGridConfigForm>
            </div>
          </Panel>
          <Panel>
            柱子样式
            <div slot="content">
              <Form :label-width="80">
                <FormItem label="柱子宽度">
                  <Input size="small" v-model="chartOption.series.symbolSize[0]" placeholder=""/>
                </FormItem>
                <FormItem label="柱子粗细">
                  <InputNumber size="small" :max="1000" :min="0" v-model="chartOption.series.symbolSize[1]"></InputNumber>
                </FormItem>
                <FormItem label="间隔">
                  <InputNumber size="small" :max="1000" :min="0" v-model="chartOption.series.symbolMargin"></InputNumber>
                </FormItem>
                <FormItem label="颜色">
                  <PnColorPicker size="small" v-model="chartOption.series.itemStyle.color" alpha recommend/>
                </FormItem>
                <FormItemPanel title="值标签">
                  <FormItem label="显示">
                    <i-switch v-model="chartOption.series.label.show">
                      <span slot="open"></span>
                      <span slot="close"></span>
                    </i-switch>
                  </FormItem>
                  <FormItem label="位置">
                    <Select :transfer="true" size="small" v-model="chartOption.series.label.position">
                      <Option v-for="item in $PnChartDict.positions" :value="item.value" :key="item.value">{{ item.label }}</Option>
                    </Select>
                  </FormItem>
                  <FormItem label="颜色">
                    <PnColorPicker size="small" v-model="chartOption.series.label.color" alpha recommend/>
                  </FormItem>
                  <FormItem label="字体大小">
                    <InputNumber size="small" :max="1000" :min="0" v-model="chartOption.series.label.fontSize"></InputNumber>
                  </FormItem>
                </FormItemPanel>
              </Form>
            </div>
          </Panel>
          <Panel>
            x轴
            <ShowToggle class="float-right" v-model="chartOption.xAxis.show"></ShowToggle>
            <div slot="content">
              <EchartsXAxisConfigForm v-model="chartOption.xAxis"></EchartsXAxisConfigForm>
            </div>
          </Panel>
          <Panel>
            y轴
            <ShowToggle class="float-right" v-model="chartOption.yAxis.show"></ShowToggle>
            <div slot="content">
              <EchartsYAxisConfigForm v-model="chartOption.yAxis"></EchartsYAxisConfigForm>
            </div>
          </Panel>
          <Panel>
            提示框
            <ShowToggle class="float-right" v-model="chartOption.tooltip.show"></ShowToggle>
            <div slot="content">
              <EchartsTooltipConfigForm v-model="chartOption.tooltip"></EchartsTooltipConfigForm>
            </div>
          </Panel>
          <Panel v-if="chartOption.title">
            标题
            <ShowToggle class="float-right" v-model="chartOption.title.show"></ShowToggle>
            <div slot="content">
              <EchartsTitleConfigForm v-model="chartOption.title"></EchartsTitleConfigForm>
            </div>
          </Panel>
          <Panel>
            其他
            <div slot="content">
              <EchartsOtherConfigForm v-model="compConfigData"></EchartsOtherConfigForm>
            </div>
          </Panel>
        </Collapse>

      </TabPane>
      <TabPane name="extend_tab" tab="main_tabs" label="扩展配置">
        <Container v-if="mainTabsValue == 'extend_tab'">
          <CustomOptionDocument :componentId="id" :customOption="customOption" :showDataZoomConfigBtn="true"></CustomOptionDocument>
          <CodeEditor v-model="customOption" mode="json"></CodeEditor>
          <EchartsSpreadingCodeForm v-model="echartsSpreadingCode"></EchartsSpreadingCodeForm>
        </Container>
      </TabPane>
      <TabPane name="datasource_tab" tab="main_tabs" label="数据源">
        <DatasourceState v-if="mainTabsValue == 'datasource_tab'" targetComp="ZebraBarChart"></DatasourceState>
      </TabPane>
      <TabPane name="interaction_tab" tab="main_tabs" label="交互">
        <Container v-if="mainTabsValue == 'interaction_tab'">
          <InteractionReceive></InteractionReceive>
          <CustomJsDocument></CustomJsDocument>
          <FormItemPanel title="初始化运行脚本">
            <CodeEditor v-model="customGlobalJsCode"></CodeEditor>
          </FormItemPanel>

          <FormItemPanel title="数据项点击时运行">
            <InteractionSender :interactionKey="'itemClick'"></InteractionSender>
            <Alert style="padding: 5px;">此脚本中，使用_this指向当前组件vm实例，通过params可获取点击项数据</Alert>
            <CodeEditor v-model="dataItemClickJsCode"></CodeEditor>
          </FormItemPanel>
        </Container>
      </TabPane>
    </Tabs>

  </div>
</template>

<script>

  import FuncCompFormMixin from '@/mixin/FuncCompFormMixin'

  import { createHelpers } from 'vuex-map-fields';

  const { mapFields } = createHelpers({
    getterType: 'designer/getLayoutItem',
    mutationType: 'designer/updateLayoutItem',
  });

  export default {
    name: 'ZebraBarChartForm', // 此名称必须填写，且必须与组件文件名相同，并且必须加上Form字符
    mixins: [FuncCompFormMixin],
    data() {
      return {}
    },
    mounted() {

    },
    methods: {},
    computed: {
      ...mapFields({

        chartOption: 'component.compConfigData.chartOption'

      })
    }
  }
</script>

<style scoped>

</style>
